/*
 * Authors: Alex Attar & Kevin El Hage
 * ID: 9765727
 * Date: 9/3/2012
 * 
 */
package taskManagerSystem.ViewSubsystem;
import javax.swing.SwingConstants;
import javax.swing.table.*;

/* The person view class inherits all the methods and variables from Table class
 * and sets the width of columns "ID" and "Total Hours" in the person table to a
 * pre-defined width, and gives focus to the table when the user clicks on the person
 * table.
 */
public class PersonView extends Table{

	public PersonView(String[] columnNames, Class<?>[] columnTypes) {
		super(columnNames, columnTypes);
		
		// helps set the cell' text alignment
		DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer();  
	    dtcr.setHorizontalAlignment(SwingConstants.LEFT);  

	    //set focus on the person table
		setSurrendersFocusOnKeystroke(true);
		
		//set the preferred and max widths of column "ID"
		TableColumn pidCol = getColumn("ID");
		pidCol.setPreferredWidth(35);
		pidCol.setMaxWidth(40);
		disableColumn(0);
		pidCol.setCellRenderer(dtcr);   // align left
		
		
		//set the preferred and max widths of column "Total Hours"
		TableColumn hoursCol = getColumn("Total Hours");
		hoursCol.setPreferredWidth(80);
		hoursCol.setMaxWidth(85);
		hoursCol.setCellRenderer(dtcr);   // align left
		
		setEnabled(false);
	}
}
